package com.cxh.dataservice.service.impl;

import com.cxh.dataservice.service.CrownService;
import com.cxh.dataservice.service.TestService;
import com.cxh.dataservice.service.ScriptService;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * Description: <br/>
 * date: 2020/6/18 15:48<br/>
 *
 * @author ChenXh<br />
 */
@Service("groovyService")
public class GroovyServiceImpl implements ScriptService {
    @Autowired
    private TestService testService;
    @Autowired
    private CrownService crownService;

    @Override
    public List<Map<String, Object>> getData(String sql, HashMap<String, String> map) {
        if (map != null && !map.isEmpty()) {
            Set<String> strings = map.keySet();

            for (String s : strings) {
                sql = sql.replaceAll(":" + s, map.get(s));
            }
        }
        return testService.getData(sql,map);
    }
}
